package com.bite.api.domain.vo;


import com.bite.api.domain.UserExeResult;
import com.bite.common.core.constants.JudgeConstants;
import com.bite.common.core.enums.CodeRunStatus;
import com.bite.common.core.enums.QuestionResType;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.List;

@Getter
@Setter
@ToString
public class UserQuestionResultVO {
    private Integer pass; // 1 表示通过 0 表示未通过

    private List<UserExeResult> exeResultList; // 执行结果

    private String errMsg; // 错误提示

    private Integer score; // 分数

    public static UserQuestionResultVO err(CodeRunStatus codeRunStatus, List<UserExeResult> exeResultList) {
        UserQuestionResultVO resultVO = new UserQuestionResultVO();
        resultVO.setPass(QuestionResType.ERROR.getValue());
        resultVO.setExeResultList(exeResultList);
        resultVO.setErrMsg(codeRunStatus.getMsg());
        resultVO.setScore(JudgeConstants.ERROR_SCORE);
        return resultVO;
    }

    public static UserQuestionResultVO err(CodeRunStatus codeRunStatus) {
        return err(codeRunStatus, null);
    }

    public static UserQuestionResultVO success(List<UserExeResult> exeResultList, Integer score) {
        UserQuestionResultVO resultVO = new UserQuestionResultVO();
        resultVO.setPass(QuestionResType.PASS.getValue());
        resultVO.setExeResultList(exeResultList);
        resultVO.setScore(score);
        return resultVO;
    }
}
